// 统一的注册所有的全局组件
import XtxSkeleton from '@/components/skeleton/index.vue'
import Xtxcarousel from '@/components/carousel/index.vue'
import XtxMore from '@/components/more/index.vue'
import Bread from './Bread/index.vue'
import BreadItem from './Bread/Item.vue'
import XtxCity from '@/components/city/index.vue'
import XtxNumbox from '@/components/numbox/index.vue'
import XtxButton from '@/components/button/index.vue'
import XtxCheckbox from '@/components/checkbox/index.vue'
import XtxMessage from '@/components/message/index.vue'
import { App } from 'vue'
import { useIntersectionObserver} from '@vueuse/core'
import defaultImg from '@/assets/images/200.png'
export default {
  install(app: App) {
    app.component('XtxSkeleton', XtxSkeleton)
    app.component('Xtxcarousel', Xtxcarousel)
    app.component('XtxMore', XtxMore)
    app.component('XtxBread', Bread)
    app.component('XtxBreadItem', BreadItem)
    app.component('XtxCity', XtxCity)
    app.component('XtxNumbox', XtxNumbox)
    app.component('XtxButton', XtxButton)
    app.component('XtxCheckbox', XtxCheckbox)
    app.component('XtxMessage', XtxMessage)
    app.directive('lazy',{
      mounted(el,binding){
        useIntersectionObserver(el,([{isIntersecting}])=>{
           if(isIntersecting){
            el.src = binding.value
           }
            el.onerror = defaultImg
       })
      }
    })
  }
  
}